package com.hebust.controller;


import com.hebust.service.AdminsService;
import com.hebust.utils.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController  // 控制层 异步的  所有控制层类都要加
@Api(value = "提供了管理员的相关接口", tags = "管理员模块")  // 类注解  对该控制器类进行功能说明
@CrossOrigin  // 解决跨域问题
public class AdminController {
    @Autowired
    private AdminsService adminsService;

    @GetMapping("/show_department")
    @ApiOperation("学院展示接口")
    public ResultVo show_department(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_department(name, pageNum);
    }

    @PostMapping("/add_department")
    @ApiOperation("学院增加接口")
    public ResultVo add_department(String name) {
        return adminsService.add_department(name);
    }

    @PutMapping("/edit_department")
    @ApiOperation("学院修改接口")
    public ResultVo edit_department(int id, String name) {
        return adminsService.edit_department(id, name);
    }

    @DeleteMapping("/delete_department")
    @ApiOperation("学院删除接口")
    public ResultVo delete_department(int id) {
        return adminsService.delete_department(id);
    }

    // -------------------------------------------------------------------------------------------------

    @GetMapping("/show_processional")
    @ApiOperation("专业展示接口")
    public ResultVo show_processional(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_processional(name, pageNum);
    }

    @PostMapping("/add_processional")
    @ApiOperation("专业增加接口")
    public ResultVo add_processional(int id, String name) {
        return adminsService.add_processional(id, name);
    }

    @GetMapping("/search")
    @ApiOperation("获取学院id和学院名字")
    public ResultVo search() {
        return adminsService.search();
    }

    @PutMapping("/edit_processional")
    @ApiOperation("专业修改接口")
    public ResultVo edit_processional(int id, String name, int region) {
        return adminsService.edit_processional(id, name, region);
    }

    @DeleteMapping("/delete_processional")
    @ApiOperation("专业删除接口")
    public ResultVo delete_processional(int id) {
        return adminsService.delete_processional(id);
    }

    // ---------------------------------------------------------------------------------------------------
    @GetMapping("/show_class")
    @ApiOperation("班级展示接口")
    public ResultVo show_class(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_class(name, pageNum);
    }

    @GetMapping("/search_class")
    @ApiOperation("获取班级id和班级名字")
    public ResultVo search_class() {
        return adminsService.search_class();
    }

    @PostMapping("/add_class")
    @ApiOperation("班级增加接口")
    public ResultVo add_class(int id, String name, int grade) {
        return adminsService.add_class(id, name, grade);
    }


    @PutMapping("/edit_class")
    @ApiOperation("班级修改接口")
    public ResultVo edit_class(int id, String name, int grade, int region) {
        return adminsService.edit_class(id, name, grade, region);
    }

    @DeleteMapping("/delete_class")
    @ApiOperation("班级删除接口")
    public ResultVo delete_class(int id) {
        return adminsService.delete_class(id);
    }


    // ---------------------------------------------------------------------------------------------------
    @GetMapping("/show_student")
    @ApiOperation("学生展示接口")
    public ResultVo show_student(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_student(name, pageNum);
    }

    @GetMapping("/search_student")
    @ApiOperation("获取学生id和学生名字")
    public ResultVo search_student() {
        return adminsService.search_student();
    }

    @PostMapping("/add_student")
    @ApiOperation("学生增加接口")
    public ResultVo add_student(int id, String name, String num, String sex, String password) {
        return adminsService.add_student(id, name, num, sex, password);
    }

    @PutMapping("/edit_student")
    @ApiOperation("学生修改接口")
    public ResultVo edit_student(int id, int cid, String name, String num, String sex, String password) {
        return adminsService.edit_student(id, cid, name, num, sex, password);
    }

    @DeleteMapping("/delete_student")
    @ApiOperation("学生删除接口")
    public ResultVo delete_student(int id) {
        return adminsService.delete_student(id);
    }


    // 教师的增删改查
    @GetMapping("/show_teacher")
    @ApiOperation("教师展示接口")
    public ResultVo show_teacher(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_teacher(name, pageNum);
    }

    @GetMapping("/search_teacher")
    @ApiOperation("获取教师所属学院名和id的对应关系")
    public ResultVo search_teacher() {
        return adminsService.search_teacher();
    }

    @PostMapping("/add_teacher")
    @ApiOperation("教师增加接口")
    public ResultVo add_teacher(int id, String name, String num, String password) {
        return adminsService.add_teacher(id, name, num, password);
    }

    @PutMapping("/edit_teacher")
    @ApiOperation("教师修改接口")
    public ResultVo edit_teacher(int id, String num, String name, String password, int did) {
        return adminsService.edit_teacher(id, num, name, password, did);
    }

    @DeleteMapping("/delete_teacher")
    @ApiOperation("教师删除接口")
    public ResultVo delete_teacher(int id) {
        return adminsService.delete_teacher(id);
    }


    // 排课的增删改查
    @GetMapping("/show_course")
    @ApiOperation("课程展示接口")
    public ResultVo show_course(String name, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_course(name, pageNum);
    }

    @GetMapping("/search_course")
    @ApiOperation("获取教师名称和id的对应关系")
    public ResultVo search_course() {
        return adminsService.search_course();
    }

    @PostMapping("/add_course")
    @ApiOperation("课程增加接口")
    public ResultVo add_course(int id, String name, int credit, String ttime, int sselect, int max, int grade, String location) {
        return adminsService.add_course(id, name, credit, ttime, sselect, max, grade, location);
    }

    @PutMapping("/edit_course")
    @ApiOperation("课程修改接口")
    public ResultVo edit_course(int id, String name, int credit, String ttime, int sselect, int max, int grade, String location, int tid) {
        return adminsService.edit_course(id, name, credit, ttime, sselect, max, grade, location, tid);
    }

    @DeleteMapping("/delete_course")
    @ApiOperation("课程删除接口")
    public ResultVo delete_course(int id) {
        return adminsService.delete_course(id);
    }

    //选课结果查询
    @GetMapping("/show_selectresult")
    @ApiOperation("选课结果展示接口")
    public ResultVo show_selectresult(String cname, String sname, @RequestParam(defaultValue = "1") int pageNum) {
        return adminsService.show_selectresult(cname, sname, pageNum);
    }

    @PutMapping("/update_studentscore")
    @ApiOperation("选课结果编辑接口")
    public ResultVo update_studentscore(int id, int score) {
        return adminsService.update_studentscore(id, score);
    }

    @DeleteMapping("/delete_selectresult")
    @ApiOperation("选课结果删除")
    public ResultVo delete_selectresult(int id) {
        return adminsService.delete_selectresult(id);
    }

}
